import my_first_model
name_list=["小明","小红","小绿"]
#取值和索引
print(name_list[2])
print(name_list.index("小明"))
print(name_list.count("小红"))
print(len(name_list))
#改动
name_list[1]="李明"
print(name_list)
#增加
name_list.insert(1,"小花")
name_list.append("Tom")
name_list2=[1,2,3]
name_list.extend(name_list2)
print(name_list)
print("*"*50)
#删除
name_list.remove("小花")
print(name_list)
name_list.pop(0)
print(name_list)
del name_list[0]
print(name_list)
i=0
while(i<len(name_list)):
    print(name_list[i],end=' ')
    i+=1
print("*"*50)
my_list=[]
for i in range(100):
    my_list.append(i)

print(my_list)
print("*"*50)
my_list2=[i for i in range(100)]#列表生成式
print(my_list2)
print("*"*50)
#列表生成式
a=[j for j in range(100)]
b=[i for j in range(5)for i in range(j)]
print(a)
print(b)
print("*"*50)
u=[i for j in range(5) for i in range (j)]
print(u)
v=[[col*row for col in range(5)] for row in range(5)]
w=[col*row for col in range(5) for row in range(5)]
print(v)
print(w)
print("-"*50)
x=[[k*w for k in range(5)]for w in range(5)]
print(x)
b=[i for j in x for i in j]#将二维列表转化为一维列表
print(b)
a=[m for m in range(10) if(m%2==0)]
print(a)
a=[m if(m%2==0) else m**2 for m in range(10)]
print(a)
print(a*2)#将列表a重复两遍
print(a+b)#等价与extend
a=[0]*100#输出100个0
print(a)
print("-"*100)
#元组
first_tuple=("张三",2104110499,1.65)
print(first_tuple)
for i in first_tuple:
    print(i)

print("*"*100)
print("姓名：%s\n学号：%d\n身高：%.2f"%first_tuple)
'''#错误写法
list=[1,2,3]
list(first_tuple)
list((3,4,5))'''
print("*"*100)
#字典
xiaoming_dict={"name":"小明"}
#获取
print(xiaoming_dict["name"])
#在取值的时候，如果指定的Key不存在，程序会报错或者返回None
#print(xiaoming_dict("name123"))
#正确操作为
print(xiaoming_dict.get("name1234"))
print("*"*100)
#增加
#如果key不存在，会增加键值对
xiaoming_dict["age"]=18
#如果key存在，会修改已经存在的键值对
xiaoming_dict["name"]="小小明"
print(xiaoming_dict)
#删除
xiaoming_dict.pop("name")
#在删除指定的键值对的时候，如果指定的Key不存在程序会报错
xiaoming_dict={"name":"小明","age":20}
print(xiaoming_dict)
print("#"*100)
#统计键值对的个数
print(len(xiaoming_dict))
#合并字典
temp_dict={"name":"小花","height":170}
#如果合并的字典包含已经存在的键值对，会覆盖原有的键值对
xiaoming_dict.update(temp_dict)
print(xiaoming_dict)

print(len(xiaoming_dict))
#遍历
print("$"*100)
#遍历
def ust_dict_iter():
    xiaoming_dict={"name":"小明","height":170,"age":18,"phone":10086}
    for i in xiaoming_dict:
        print(i,xiaoming_dict[i])
    print("\n")
    for k,v in xiaoming_dict.items():
        print(k,v)
ust_dict_iter()
#九九乘法表
def func1():
    for i in range(1,10):
        for j in range(1,i+1):
            print(f'{j}*{i}={j*i:<2d}',end=' ')
        print(" ")
func1()
a='11035'
print(a.count('1'))
a=132
b=bin(a)
print(b)
print(type(b))
#输入一个十进制的整数，输出整数转化为二进制数时的1的个数
'''def func2():
    num=int(input("请输入一个整数："))
    if num>0:
      b=bin(num)
      print(b.count('1'))
    else:
        print(64-bin(~num).count('1'))
func2()
print(bin(-5))'''
def func3():
    num=int(input("请输入一个整数："))
    count=0
    check_flag=1
    for i in range(64):
        if(num&check_flag):
            count+=1
        check_flag<<=1
    print(count)
func3()
